home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7635 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  47 lines

  1. Path: thor.tu.hac.com!collins
  2. From: collins@thor.tu.hac.com (Ron Collins)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Do you have ever pass structures?
  5. Date: 27 Feb 1996 18:54:46 GMT
  6. Organization: Advanced Depot Systems
  7. Message-ID: <4gvk1m$8sa@hacgate2.hac.com>
  8. References: <4ge8mi$qjm@srvr1.engin.umich.edu> <4ggsio$343@news-f.iadfw.net> <4gqk11$e7l@airdmhor.gen.nz> <4gtm62$gjb@sam.inforamp.net>
  9. NNTP-Posting-Host: thor.tu.hac.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Lew Pitcher (pitchl@tdbank.ca) wrote:
  13. : gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
  14.  
  15. : >Adam Peterson:
  16. : >> The *disadvantage* is speed and space. Passing a pointer is just
  17. : >> word//double word.  Passing the actual structure requires loading the
  18. : >> stack with all the elements of the structure...slow...
  19.  
  20. : >  But once it's done you don't have this pointer-thing to dereference all
  21. : >the time (of course, this depends on how much register space you have - will
  22. : >I ever get over my Intelesque hangups?).
  23.  
  24. : Yah, but you still wind up dereferencing a pointer (just this time
  25. : it's the stack pointer).
  26.  
  27. No ... if I pass a structure on the stack, _I_ never have to dereference
  28. a pointer at all.  The compiler will do that for me.
  29.  
  30. :                          If you really want efficiency, then define a
  31. : global structure variable, put your data into it, and let the called
  32. : function access it directly. There should be less pointer
  33. : dereferencing that way.
  34.  
  35. What -- you don't think the compiler generates a pointer to a global area,
  36. the same as it does to a stack or heap object?
  37.  
  38.  
  39.                         -- Collins --
  40.                         
  41. -----
  42. The views expressed here are mine alone.
  43.  
  44. Ron Collins/Hughes Aircraft Company/M20,P20/Tucson Az 85706
  45. rcollins@thor.tu.hac.com    collins@seagull.rtd.com
  46. ยก----
  47.